﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Skyhook.Core;
using Skyhook.Resources;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;

namespace Skyhook.Sprites
{
	internal class Sprite
	{
        ImageCollection Image = null;
        Range FramesRange = null;
        int pCurrentFrame = 0;

        public bool IsRendered = false;

        public Sprite(ImageCollection image, int framestart, int framescount)
        {
            Image = image;
            FramesRange = new Range(framestart, framescount + framestart - 1);
            pCurrentFrame = 0;
        }

        public Texture2D Texture
        {
            get
            {
                return Image.Texture;
            }
        }

        public int FramesCount
        {
            get
            {
                return FramesRange.Count;
            }
        }

        public int CurrentFrame
        {
            get
            {
                return pCurrentFrame;
            }
            set
            {
                pCurrentFrame = value;
            }
        }

        public virtual Rectangle TextureRectangle
        {
            get
            {
                return Image.GetFrameRect(FramesRange[pCurrentFrame]);
            }
        }

        public virtual Vector2 CenterPoint
        {
            get
            {
                return Image.GetCenterPoint(FramesRange[pCurrentFrame]);
            }
        }

        public virtual Sprite Clone()
        {
            Sprite result = (Sprite)this.MemberwiseClone();
            return result;
        }
	}
}
